package com.ruoyi.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.domain.T06;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.service.IPcService;
import com.ruoyi.service.IT06Service;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/pcl")
public class PCcontroller {
    @Autowired
    private ISysUserService sysUserService;
    @Autowired
    private IPcService pcService;
    @Autowired
    private TokenService tokenService;
    @Autowired
    private IT06Service t06Service;
    @GetMapping("/list")
    public AjaxResult getList(HttpServletRequest request){
        Long userId=tokenService.getLoginUser(request).getUser().getUserId();
        SysUser user=sysUserService.selectUserById(userId);
        Long deptId=user.getDeptId();
        return AjaxResult.success(pcService.getUserList(userId));
    }
    @GetMapping("getuser/{userId}")
    public AjaxResult getUser(@PathVariable("userId") Long userId){
        return AjaxResult.success(t06Service.selectT06ByF0601(userId));
    }
    @PutMapping("/update")
    public AjaxResult updateUser(@RequestBody T06 t06){
        return AjaxResult.success(t06Service.updateT06(t06));
    }
    @PostMapping("delete")
    public AjaxResult deleteUser(@RequestBody Long userId){
        return AjaxResult.success(t06Service.deleteT06ByF0601(userId));
    }
}
